package tests;



import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import application.ProjectStatistics;
import application.Projects;
import application.TextReader;
import application.extractRow;

public class ProjectStatisticsTest {

	private ProjectStatistics ps1; 
	private ProjectStatistics ps2; 
	private ProjectStatistics ps3; 
	private TextReader tr;
	private Projects p;
	private extractRow er;
	
	@Before
	public void setUp() throws Exception {
		//tr = new TextReader("ETSF01-Data-Text-txt");
//		ps1 = new ProjectStatistics("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10","11", "12", "13", "14", 15, 16);
//		ps2 = new ProjectStatistics("10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "110","111", "112", "113", "114", 115, 116);
//		ps3 = new ProjectStatistics("20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "210","211", "212", "213", "214", 215, 216);
		p = new Projects();
		p.addProject(ps1);
		p.addProject(ps2);
		p.addProject(ps3);
		er = new extractRow(p);
	}

	
	@Test
	public void testGetRelay() {
		assertEquals("0",ps1.getRely());
		
	}
	
	@Test
	public void testGetData(){
		assertEquals("1",ps1.getData());
	}
	
	
	@Test
	public void testGetcplx(){
		assertEquals("2",ps1.getCplx());
	}
	
	@Test
	public void testGetTime(){
		assertEquals("3",ps1.getTime());
	}
	@Test
	public void testGetStor(){
		assertEquals("4",ps1.getStor());
	}
	@Test
	public void testGetVirt(){
		assertEquals("5",ps1.getVirt());
	}
	@Test
	public void testGetTurn(){
		assertEquals("6",ps1.getTurn());
	}
	@Test
	public void testGetAcap(){
		assertEquals("7",ps1.getAcap());
	}
	@Test
	public void testGetAexp(){
		assertEquals("8",ps1.getAexp());
	}
	@Test
	public void testGetPcap(){
		assertEquals("9",ps1.getPcap());
	}
	@Test
	public void testGetVexp(){
		assertEquals("10",ps1.getVexp());
	}
	
	@Test
	public void testGetLexp(){
		assertEquals("11",ps1.getLexp());
	}
	@Test
	public void testGetModp(){
		assertEquals("12",ps1.getModp());
	}
	@Test
	public void testGetTool(){
		assertEquals("13",ps1.getTool());
	}
	@Test
	public void testGetSced(){
		assertEquals("14",ps1.getSced());
	}
	
	@Test
	public void testGetKsloc(){
		assertEquals(15,ps1.getKsloc(),5);
	}
	@Test
	public void testGetActualEffort(){
		assertEquals(16,ps1.getActualEffort(),5);
	}
	
	
	@Test
	public void testProjectsGet(){
		ProjectStatistics pstemp = p.getProject(1);
		assertEquals("10",pstemp.getRely());
		assertEquals("11",pstemp.getData());
		assertEquals("12",pstemp.getCplx());
		assertEquals("13",pstemp.getTime());
		assertEquals("14",pstemp.getStor());
		assertEquals("15",pstemp.getVirt());
		assertEquals("16",pstemp.getTurn());
		assertEquals("17",pstemp.getAcap());
		assertEquals("18",pstemp.getAexp());
		assertEquals("19",pstemp.getPcap());
		assertEquals("110",pstemp.getVexp());
		assertEquals("111",pstemp.getLexp());
		assertEquals("112",pstemp.getModp());
		assertEquals("113",pstemp.getTool());
		assertEquals("114",pstemp.getSced());
		assertEquals(115,pstemp.getKsloc(),5);
		assertEquals(116,pstemp.getActualEffort(),5);
	
	}
	
	@Test
	public void testProjectsGetBadArrayNr(){
		ProjectStatistics pstemp = p.getProject(-1);
		ProjectStatistics pstemp2 = p.getProject(3);
		assertEquals(null,pstemp);
		assertEquals(null,pstemp2);
	}
	
	
	@Test
	public void testProjectSsize(){
		assertEquals(3,p.getSize());
		ProjectStatistics pstemp = p.getProject(0);
		assertEquals(3,p.getSize());
	}
	
	@Test
	public void testExtractRow(){
		ArrayList<ProjectStatistics> temp = er.build(2);
		assertEquals(2,temp.size());
		ProjectStatistics pstemp = er.getExtractedRow();
		assertEquals("20",pstemp.getRely());
		assertEquals("21",pstemp.getData());
		assertEquals("22",pstemp.getCplx());
		assertEquals("23",pstemp.getTime());
		assertEquals("24",pstemp.getStor());
		assertEquals("25",pstemp.getVirt());
		assertEquals("26",pstemp.getTurn());
		assertEquals("27",pstemp.getAcap());
		assertEquals("28",pstemp.getAexp());
		assertEquals("29",pstemp.getPcap());
		assertEquals("210",pstemp.getVexp());
		assertEquals("211",pstemp.getLexp());
		assertEquals("212",pstemp.getModp());
		assertEquals("213",pstemp.getTool());
		assertEquals("214",pstemp.getSced());
		assertEquals(215,pstemp.getKsloc(),5);
		assertEquals(216,pstemp.getActualEffort(),5);
	}
	
	
}
